import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mandoby/core/utils/app_strings.dart';
import 'package:mandoby/features/Choosing_college/presentation/pages/choose_college_screen.dart';
import 'package:mandoby/features/splash/splash_screen.dart';
import 'package:mandoby/features/universities_available/presentation/pages/universities_available_screen.dart';
import 'package:mandoby/page_config.dart';
import 'package:mandoby/web_page.dart';
import 'package:nb_utils/nb_utils.dart';
import 'core/app_export.dart';
import 'features/nationally/presentation/pages/nationally_screen.dart';
import 'features/plans/presentation/pages/plans_screens.dart';
import 'features/university_category/presentation/pages/university_category_screen.dart';

var globalMessengerKey = GlobalKey<ScaffoldMessengerState>();
var globalNavigationKey = GlobalKey<NavigatorState>();

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

  pageRouteAnimationGlobal = PageRouteAnimation.Fade;
  loadPageConfig().then((value) => {
    if (value.isEnable) {
      runApp(WebPage(pageData: value))
    } else {
      runApp(MyApp())
    }
  });
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Sizer(
      builder: (context, orientation, deviceType) {
        return MaterialApp(
            navigatorKey: globalNavigationKey,
            scaffoldMessengerKey: globalMessengerKey,
            theme: theme,
            title: AppStrings.appName,
            builder: AppLocalization.directionBuilder,
            debugShowCheckedModeBanner: false,
            home:  SplashScreen()
            //  routes: AppRoutes.routes,
            );
      },
    );
  }
}

class AppLocalization {
  static Widget directionBuilder(BuildContext context, Widget? child) {
    return Directionality(
      textDirection: TextDirection.rtl,
      child: child ?? const SizedBox(),
    );
  }
}
